// 分页组件的再封装

<script setup>
const props = defineProps({
  // 条数分类
  pageSizes: {
    type: Array,
    default: () => [10, 20, 30, 40],
  },
  pageInfo: {
    type: Object,
    require: true,
    default: () => {},
  },
});

const emit = defineEmits();

const handleCurrentChange = (newVal) => {
  props.pageInfo.current = newVal;
  emit("handleCurrentChange", newVal);
};
const handleSizeChange = (newVal) => {
  props.pageInfo.size = newVal;
  emit("handleSizeChange", newVal);
};
</script>

<template>
  <div class="x-pagination">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageInfo.current"
      :page-sizes="pageSizes"
      :page-size="pageInfo.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageInfo.total"
    ></el-pagination>
  </div>
</template>

<style lang="scss">
.x-pagination {
  .el-pagination {
    display: flex;
    justify-content: flex-end;
  }
}
</style>
